Struts 2 is a web application framework based on the Model-View-Controller (MVC) pattern. It automates common tasks to make developing large web applications easier and faster. Struts 2 uses interceptors and actions to implement the MVC pattern, with actions representing the model, results representing views, and a filter dispatcher acting as the controller. Developers can declare the framework's architecture either through XML configuration files or Java annotations.
2. What is Framework ? Set of classes and interfaces that co-operate to solve a specific problem. Tries to make generalizations about the common tasks and work flow of a specific domain. Automates common tasks. Provide architectural solution.
3. Why to Use Framework ? Make the HUGE web application development easy. Saves time of developers because it automates all tedious tasks of development. Provides a platform upon which applications can be more quickly build.
4. What is Struts 2 ? A brand-new web application framework. Based on OpenSymphony Web Works Framework . Follows well established MVC (Model-View-Controller) design pattern. Also Known as WebWorks2.
5. Whats in Struts 2 ? MVC is implemented by action, result and FilterDispatcher. Controller is FilterDispatcher , Model is Action and View is Result Controller(FilterDispatcher) is responsible for mapping users requests to appropriate action. Invocation of action should pass through a series of interceptors as defined in the application's XML file Model(Action) contains DATA and business logic. View is implemented using JSP , Velocity Template , Freemaker etc.
7. Whats in Struts 2 ? Struts 2 uses two mechanisms for declaring architecture. XML – Based declarative architecture. JAVA – Annotations Based Declarative architecture
8. XML Based Declarative Architecture XML Documents consist of elements that represent the components of the application. Mainly contains struts.xml as entry point
9. Java Annotations Based Declarative Architecture Annotations allows you to add meta-data directly to JAVA source files. Made on the Java classes that implement the actions. They contain meta-data that the framework uses to create the runtime components of your application.